<template>
  <div>
    <van-address-edit
      :area-list="areaList"
      show-search-result
      :search-result="searchResult"
      :area-columns-placeholder="['请选择', '请选择', '请选择']"
      @save="onSave"
    />
  </div>
</template>
<script>
import Vue from "vue";
import { AddressEdit, Toast } from "vant";
import areaList from "@/utils/area.js";
Vue.use(AddressEdit);
Vue.use(Toast);
import { postAddress } from "@/api/address";
export default {
  components: {},
  data() {
    return {
      areaList,
      searchResult: []
    };
  },
  created() {},
  methods: {
    onSave(res) {
      let address = {
        province: res.province,
        city: res.city,
        country: res.county,
        detail: res.addressDetail,
        mobile: res.tel,
        name: res.name
      };
      postAddress(address).then(res => {
          Toast('你真棒!');
          this.$router.go(-1)
      });
    }
  }
};
</script>

<style lang="scss" scoped>
</style>